RippleSampler : SampleSynthDescriptor{
	

		
	createGuiControls{ 
		
		this.put(\loopLength, 		c.new(default: 1, min: 0.02, max: 2, midiNum:53) );
		this.put(\pitchUp, 		c.new(default: 0, max:5, theLog:3) );
		this.put(\pitchDown,  	c.new(default: 0, max:0.9, midiNum:55, theLog:3) );
		
	}
	
	*loadSynth{
	
		
		SynthDef(
					
			this.getSynthName,
			{
				arg 
				len = 1, 
				startOffset = 0, 
				bufnum, 
				attack = 0.05, 
				decay = 0.05, 
				volume = 0.7,
				volume2 = 1, 
				tremeloFreq = 0, 
				tremeloDepth = 0,
				tremeloRand = 0,
				pan = 0,
				pitchRatio = 1,
				loopLength,
				pitchUp, 
				pitchDown,
				busNum,
				eqFreq = 100,
				eqLevel = -7,
				eqRq = 0.4;
				
				var p, c, startFrames, endLoop, loopFrames, numChannels, maxLoopLength;
				
				maxLoopLength = BufFrames.kr(bufnum);
				
				startFrames = maxLoopLength * startOffset; 
				
				loopFrames = loopLength * SynthConstants.getLoopResution;
				loopFrames = if( loopLength > 0.95, maxLoopLength, loopFrames );
				endLoop = (startFrames + loopFrames).min( BufFrames.kr(bufnum) );
				
				
				p = LoopBuf.ar(
					2,
					bufnum, 
					BufRateScale.kr(bufnum) * pitchRatio * (pitchUp + 1) * (1 - pitchDown), 
					startPos: startFrames,
					startLoop: startFrames,
					endLoop: endLoop,
					gate:1);
				
				p = if( BufChannels.kr(bufnum) > 1, 
					(
						Balance2.ar(
							p[0], // left
							p[1], // right
							pan
						)
					),
					(
						Pan2.ar(
							p,
							pan // this is pan
						)	
					)
				  );
				  
				  
				p = MidEQ.ar(p, eqFreq, eqRq, eqLevel);
				  
				Out.ar(busNum, 
					p
				);
				
				
			}
			
		).load(Server.default);
	
	}

}

RippleLongSampler : RippleSampler{

	createGuiControls{
		super.createGuiControls;
		this.put(\len, 			c.new(default: 0, max: 5, midiNum:8) );
		this.put(\attack, 		c.new(default: 0.05, max: 10, midiNum:9) );
		this.put(\decay, 			c.new(default: 0.05, max: 10, midiNum:10) );
		this.put(\timescale,  	c.new(default: 1, min: 0.03, max: 20,  midiNum:14) );
	}
}
	
/*	
RippleVerbSampler : RippleSampler{
	

	*playSound{|args, group, buffer|
		super.playSound(args, group, buffer);
		Synth.tail(group, "verb", args);
		ArrayUtils.setValueInSynthArgs(args, \len, 5);
	}
	
	createGuiControls{
		
		super.createGuiControls;
		
		this.put(\mix, 			c.new(default: 0.5) );
		this.put(\room, 			c.new(default: 0.5) );
		this.put(\damp, 			c.new(default: 0.5) );
		
		
	}
			
	*loadSynth{
		super.loadSynth;
		
		SynthDef("verb",{| mix = 0.9, room = 0.01, damp = 0, busNum|
			var input, output, clean, wet;
	
			clean = In.ar(busNum,2);
			wet = FreeVerb.ar(clean, mix, room, damp);
	
			output = wet;
			
			//send to chosen outbus
			ReplaceOut.ar(0,output);
		}).send(Server.default);
		
	}
}
*/

